# -*- coding = utf-8 -*-
# @Time : 2021/12/27 16:16
# @Author : 龙王赘婿_彪少
# @File : testclass.py
# @Software: PyCharm

# 面向对象编程

class Parent():
    # 类文档字符串 __doc__
    '父类'
    # 类变量 两种调用方式
    obj_number = 0
    # 私有变量
    __privatevalue = 1

    # 构造函数
    def __init__(self):
        print("构造函数")
        self.va = None
        self.obj_number = self.obj_number + 1

    # 析构函数
    def __del__(self):
        print("析构函数")

    # self 代表对象，不代表类本身
    def prt(self):
        print(self)
        print(self.__class__)

    # 重载运算符
    def __add__(self, other):
        return self.obj_number + other.obj_number


class Child(Parent):
    def __init__(self):
        super(Child, self).__init__()
        print("子类构造函数")

if __name__ == '__main__':
    # 类调用类变量
    print(Parent.obj_number)
    # 创建类
    p1 = Parent()
    print(p1.obj_number)
    p1.prt()
    c1 = Child()
    print(p1 + c1)
    del p1

    # 内置属性
    # print("Parent.__doc__:", Parent.__doc__)
    # print("Parent.__name__:", Parent.__name__)
    # print("Parent.__module__:", Parent.__module__)
    # print("Parent.__bases__:", Parent.__bases__)
    # print("Parent.__dict__:", Parent.__dict__)


